package com.yanqu.road.server.cmd.activity;

import com.yanqu.road.entity.rank.stronghold.CrossActivityUnionRank;
import com.yanqu.road.logic.pb.CrossRankPb;
import com.yanqu.road.pb.cross.activity.CrossActivityProto;
import com.yanqu.road.pb.rank.UnionActivityRankProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.activity.CrossGeneralActivityRankMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C_CROSS_GENERAL_ACTIVITY_UNION_RANK_CHANGE, desc = "跨服活动商会数据变更")
public class CrossGeneralActivityUnionRankChangeCmd extends CrossCommand {

    private int activityId;

    private boolean isAll;

    private boolean isUnionDel;

    private int conditionType;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        CrossActivityProto.CrossActivityUnionRankChangeReqMsg reqMsg = CrossActivityProto.CrossActivityUnionRankChangeReqMsg.parseFrom(packet.getBytes());
        isAll = reqMsg.getIsAll();
        activityId = reqMsg.getActivityId();
        isUnionDel = reqMsg.getIsUnionDel();
        conditionType = reqMsg.getConditionType();
        for (UnionActivityRankProto.UnionActivityRankTempMsg tempMsg : reqMsg.getDataListList()) {
            CrossActivityUnionRank unionActivityRank = CrossRankPb.parseCrossUnionActivityRank(activityId, tempMsg);
            unionActivityRank.setServerId(serverId);
            CrossGeneralActivityRankMgr.changeStrongholdUnionRank(activityId, conditionType, unionActivityRank, isUnionDel);
        }
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {

    }

    @Override
    public void sendData() {

    }
}
